package com.zghhost.codedemo;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class FetchAllZhaopinDep {
    public static void main(String[] args)throws Exception{
        printAll("http://172.17.0.59:8081/nexus/content/groups/public/com/zhaopin/");

    }

    static void printAll(String purl)throws Exception{
        Document doc = Jsoup.connect(purl).get();
        Elements trs = doc.select("tbody").eq(0).select("tr");
        for(Element tr : trs){
            if(tr.toString().indexOf("zhaopin") != -1){
                String url = tr.select("a").eq(0).attr("href");
                printDep(url);
            }
        }
    }

    static void printDep(String purl)throws Exception{
        Document doc = Jsoup.connect(purl).get();
        if(doc.toString().indexOf(".xml") == -1){
            doc = Jsoup.connect(purl).get();
        }
        if(doc.toString().indexOf(".xml") == -1){
            doc = Jsoup.connect(purl).get();
        }
        if(doc.toString().indexOf(".xml") == -1){
//            printAll(purl);
            return;
        }
//        System.out.println("-============"+purl);
        Elements trs = doc.select("tbody").eq(0).select("tr");
        String url = trs.get(trs.size()-4).select("a").eq(0).attr("href");
        String[] pathArr = url.split("/");
        System.out.println("compile \"com.zhaopin:"+pathArr[pathArr.length-2]+":"+pathArr[pathArr.length-1]+"\"");
    }
}
